//封装axios
import axios from 'axios';
const service = axios.create({
    baseURL: '/api'// api的base_url
});
//添加请求拦截器
service.interceptors.request.use(
    config => {
        console.log("qingqiuqian");
        return config;
    },
    error => {
        //请求错误
        console.log(error);
        return Promise.reject();
    }
);
//添加响应拦截器
service.interceptors.response.use(
    response => {
        if (response.data.code === 200) {
            return response.data;
        } else if (response.data.code != 200) {
            // console.log(response);
            //response.status = response.data.code
            // ElementUI.Message({
            // 	message: response.data.message,
            // 	type: 'error'
            // });
            return Promise.reject();
        }
    },
    error => {
        console.log(error, "error");
        return Promise.reject();
    }
);
export default service;
